﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Collections.Concurrent;

namespace ReactiveLang
{
    class TestSyncContext: SynchronizationContext
    {
        ConcurrentQueue<Action> _queue = new ConcurrentQueue<Action>();
        public override void Post(SendOrPostCallback d, object state)
        {
            _queue.Enqueue(() => d(state));
        }
        public void RunQueue()
        {
            Action action;
            while (_queue.TryDequeue(out action))
                action();
        }
    }
}
